/**
 *
 */
package com.angel.io.validators.impl;

import java.lang.reflect.Constructor;

import com.angel.io.exceptions.RowProcessorCommandValidatorException;
import com.angel.io.validators.RowProcessorCommandValidator;

/**
 * @author William
 *
 */
public class DefaultConstructorRowProcessorCommandValidator implements RowProcessorCommandValidator{

	public void validate(Class<?> importRowCommandClass) throws RowProcessorCommandValidatorException {
		Constructor<?>[] constructors = importRowCommandClass.getConstructors();
		boolean foundDefault = false;
		for(Constructor<?> c: constructors){
			if(!foundDefault && (c.getParameterTypes() == null || c.getParameterTypes().length == 0)){
				foundDefault = true;
			}
		}
		if(!foundDefault){
			throw new RowProcessorCommandValidatorException("Class [" + importRowCommandClass.getCanonicalName() + "] must implements a defaut constructor.");
		}
	}


}
